    package com.example.boke.entity;

    import com.baomidou.mybatisplus.annotation.IdType;
    import com.baomidou.mybatisplus.annotation.TableField;
    import com.baomidou.mybatisplus.annotation.TableId;
    import com.example.boke.mapper.TypeMapper;
    import org.springframework.beans.factory.annotation.Autowired;

    import java.time.LocalDateTime;
    import java.io.Serializable;
    import java.util.ArrayList;
    import java.util.List;


    /**
    * <p>
    *
    * </p>
    *
    * @author admin
    * @since 2021-05-03
    */

public class Blog implements Serializable {

    private static final long serialVersionUID=1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    private Boolean appreciation;

    private Boolean commentabled;

    private String content;

    private LocalDateTime createTime;

    private String firstPicture;

    private String flag;

    private Boolean published;

    private Boolean recommend;

    private Boolean shareStatement;

    private String title;

    private LocalDateTime updateTime;

    private Integer views;

    private Long typeId;

    private Long userId;

    @TableField(exist = false)
    private  List<Tag> tagList;

    @TableField(exist = false)
    private Type Type;



    public static long getSerialVersionUID() {
    return serialVersionUID;
    }

        public List<Tag> getTagList() {
            return tagList;
        }

        public void addtag(Tag tag) {
            this.tagList.add(tag);
        }

        public com.example.boke.entity.Type getType() {
            return Type;
        }

        public void setType(com.example.boke.entity.Type type) {
            Type = type;
        }

        public Long getId() {
    return id;
    }

    public void setId(Long id) {
    this.id = id;
    }

    public Boolean getAppreciation() {
    return appreciation;
    }

    public void setAppreciation(Boolean appreciation) {
    this.appreciation = appreciation;
    }

    public Boolean getCommentabled() {
    return commentabled;
    }

    public void setCommentabled(Boolean commentabled) {
    this.commentabled = commentabled;
    }

    public String getContent() {
    return content;
    }

    public void setContent(String content) {
    this.content = content;
    }

    public LocalDateTime getCreateTime() {
    return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
    this.createTime = createTime;
    }

    public String getFirstPicture() {
    return firstPicture;
    }

    public void setFirstPicture(String firstPicture) {
    this.firstPicture = firstPicture;
    }

    public String getFlag() {
    return flag;
    }

    public void setFlag(String flag) {
    this.flag = flag;
    }

    public Boolean getPublished() {
    return published;
    }

    public void setPublished(Boolean published) {
    this.published = published;
    }

    public Boolean getRecommend() {
    return recommend;
    }

    public void setRecommend(Boolean recommend) {
    this.recommend = recommend;
    }

    public Boolean getShareStatement() {
    return shareStatement;
    }

    public void setShareStatement(Boolean shareStatement) {
    this.shareStatement = shareStatement;
    }

    public String getTitle() {
    return title;
    }

    public void setTitle(String title) {
    this.title = title;
    }

    public LocalDateTime getUpdateTime() {
    return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
    this.updateTime = updateTime;
    }

    public Integer getViews() {
    return views;
    }

    public void setViews(Integer views) {
    this.views = views;
    }

    public Long getTypeId() {
    return typeId;
    }

    public void setTypeId(Long typeId) {
    this.typeId = typeId;
    }

    public Long getUserId() {
    return userId;
    }

    public String getOmitcontent()
    {
        int count = this.content.length();
        //取总数的10分之一
        count = (int) (count * 0.1);
        return this.content.trim().substring(0,count);
    }

    public void setUserId(Long userId) {
    this.userId = userId;
    }
    public Blog(){

    this.tagList = new ArrayList<>();

    this.createTime = LocalDateTime.now();
    this.updateTime = LocalDateTime.now();

    this.appreciation=false;
    this.commentabled=false;
    this.shareStatement=false;
    this.recommend=false;

    this.views = 0;

    }


    public String getCreateDate(){

        String updateTime = this.createTime+"";

        int length = updateTime.length();


        return updateTime.substring(0,length-16).replaceAll("T"," ");
    }

        public String getCreateDateTime() {

            String updateTime = this.getCreateTime()+"";
            int length = updateTime.length();
            return updateTime.substring(0,length-7).replaceAll("T"," ");

        }




        @Override
    public String toString() {
    return "Blog{" +
            "id=" + id +
            ", appreciation=" + appreciation +
            ", commentabled=" + commentabled +
            ", content='" + content + '\'' +
            ", createTime=" + createTime +
            ", firstPicture='" + firstPicture + '\'' +
            ", flag='" + flag + '\'' +
            ", published=" + published +
            ", recommend=" + recommend +
            ", shareStatement=" + shareStatement +
            ", title='" + title + '\'' +
            ", updateTime=" + updateTime +
            ", views=" + views +
            ", typeId=" + typeId +
            ", userId=" + userId +
            '}';
    }
}
